package com.epam.facebook_client.manager;

import java.io.File;

import android.content.Context;

public class CacheManager {

	public static final String SERVICE_NAME = "--CAHCE_MANAGER--";
	
	private Context context;
	private static final int MAX_SIZE = 5 * 1024 * 1024;

	public CacheManager(Context context) {
		this.context = context;
	}
	
	public static CacheManager get(Context context){
		return (CacheManager) context.getApplicationContext().getSystemService(SERVICE_NAME);
	}
	
	public int clearCache(){
		File[] listFiles = context.getCacheDir().listFiles();
		int size = 0;
		for (File file : listFiles) {
			boolean delete = file.delete();
			if(delete){
				size++;
			}
		}
		return size;
	}
}
